<?php
include_once('common/header.php');
if($AppUI->id <= 0 || (isset($_SESSION['content']) && (($_SESSION['content']&1<<1) == 0)) || $AppUI->type < 2) {
	Vfriend_Function::redirect(HOST_BACKEND);
}
$strPage		= $objRequest->getParam('ppage', '');
$strSection		= $objRequest->getParam('psection', '');
$strName		= $objRequest->getParam('pname', '');
$strContent		= $objRequest->getParam('pcontent', '');
$strNameEn		= $objRequest->getParam('pname_en', '');
$strContentEn	= $objRequest->getParam('pcontent_en', '');
$intError		= 0;
if($strPage == '') $intError = 3;
elseif($strPage != '' && strlen($strPage) < 2 && strlen($strPage) > 50) $intError = 4;
elseif($strPage != '' && !Vfriend_Function::isValidCode($strPage)) $intError = 5;
elseif($strName == '') $intError = 6;
elseif($strName != '' && strlen($strName) < 5) $intError = 7;
elseif(strip_tags($strContent) == '') $intError = 8;
elseif($strContent != '' && strlen(strip_tags($strContent)) < 20) $intError = 9;
/*elseif($strNameEn == '') $intError = 10;
elseif($strNameEn != '' && strlen($strNameEn) < 5) $intError = 11;
elseif(strip_tags($strContentEn) == '') $intError = 12;
elseif($strContentEn != '' && strlen(strip_tags($strContentEn)) < 20) $intError = 13;*/
if($intError == 0) {
	if(isset($_SESSION['post'])) unset($_SESSION['post']);
	if(isset($_SESSION['cerr'])) unset($_SESSION['cerr']);
	$objContent = new Content();
	$intError	= $objContent->add($AppUI->id, $strPage, $strSection, $strName, $strContent, $strNameEn, $strContentEn);
	if($intError == 0) {
		Vfriend_Function::setMsg($arrMessage[1]);
		Vfriend_Function::redirect(HOST_BACKEND . 'content/index');
	}
}
if($intError > 0) {
	$_SESSION['post']	= $objRequest->getParams();
	$_SESSION['cerr']	= $arrError[$intError];
	Vfriend_Function::redirect(HOST_BACKEND . 'content/add');
}
?>